<!-- 流失患者 -->
<template>
    <Card>
        <jgSearch
            :searchData="searchData"
            @on-change-change="askDataing"
            @on-change-changes="getDatas"
            @on-enter-input="inputaskData"
            @on-clear-input="inputaskData">
            <template v-slot:arrivedradio>
                <RadioGroup
                    type="button"
                    v-model="type"
                    @on-change="changetype(type)"
                >
                    <Radio :label="2">今</Radio>
                    <Radio :label="1">昨</Radio>
                    <Radio :label="5">月</Radio>
                </RadioGroup>
            </template>
        </jgSearch>
        <tablelist
            @askData="askDatas"
            :params="params"
            :columns="columns"
            :list="list"
            :loading="loading"
            :total="total"
            currentTab="arrived"/>
    </Card>
</template>
<script>
    import { losslist,patientindextabtotal} from '@/api/hqapi';
    import jgSearch from '@/components/search';
    // import jgcheckcity from '@/components/checkcity';
    import tablelist from './tablelist';
    import mixins from './mixins';
    export default {
        name: 'arrivedpatient',
        components: { tablelist, jgSearch },
        mixins: [mixins],
        data () {
            return {
                searchData: {
                    project: [
                        { id: 1, key: 'slot', keys: 'arrivedradio' },
                        { id: 4, key: 'DatePicker', transfer: true, format: 'yyyy-MM-dd', placeholder: '请选择已到时间', options: { disabledDate (date) { return date && date.valueOf() > Date.now() } }, style: { width: '200px' }, value: [new Date(), new Date()], type: 'daterange', callback: 'changes' },
                        // { id: 5, key: 'Input', placeholder: '请输入患者姓名/手机号/微信号/唯一身份', clearable: true, style: { width: '270px' }, value: '', callback: 'input' },
                        { id: 7, key: 'Select', transfer: true, style: { minWidth: '100px' }, placeholder: '归属人', Group: true, value: '', childList: [], clearable: true, callback: 'change' },
                        { id: 8, key: 'TreeSelect', transfer: true, style: { minWidth: '100px' }, placeholder: '病种', value: '', childList: [], clearable: true, callback: 'change' },
                        // { id: 12, key: 'Select', transfer: true, style: { minWidth: '100px' }, placeholder: '对话方式', value: '', childList: [], clearable: true, callback: 'change' },
                        // { id: 20, key: 'Select', transfer: true, style: { minWidth: '100px' }, placeholder: '部位', multiple: true, maxTagCount: 3, value: [], childList: [], clearable: true, callback: 'change' },
                        { id: 9, key: 'TreeSelect', transfer: true, maxTagCount: 3, style: { minWidth: '100px' }, placeholder: '渠道来源', multiple: true, value: [], childList: [], clearable: true, callback: 'change' },
                        // { id: 13, key: 'slot', keys: 'city' }
                    // { id: 11, key: 'Select', style: { minWidth: '100px' }, placeholder: '城市', value: '', childList: [], clearable: true, callback: 'change'},
                    ]
                },
                options: { disabledDate (date) { return date && date.valueOf() > Date.now() } },
                columns: [
                    {
                        title: '基本信息',
                        key: 'basic',
                        slot: 'info',
                        width: 135,
                        fixed: 'left'
                    },
                    { title: '患者状态', key: 'state', slot: 'state', width: 100 },
                    { title: '归属人', key: 'realname', width: 120 },
                    {
                        title: '已到时间',
                        key: 'revisiting_time_str',
                        sortable: 'custom',
                        width: 108
                    },
                    {
                        title: '回访次数',
                        key: 'callback_count',
                        sortable: 'custom',
                        width: 108
                    },
                    {
                        title: '未访天数',
                        sortable: 'custom',
                        key: 'uncallback_day',
                        filteredValue: [],
                        filters: [
                            {
                                label: '0-10天未访',
                                value: '1'
                            },
                            {
                                label: '11-20天未访',
                                value: '2'
                            },
                            {
                                label: '21-30天未访',
                                value: '3'
                            },
                            {
                                label: '31-60天未访',
                                value: '4'
                            },
                            {
                                label: '60天以上未访',
                                value: '5'
                            }
                        ],
                        filterMultiple: false,
                        filterRemote (value) {
                            this.filterType = value[0];
                        },
                        width: 130
                    },
                    {
                        title: '未到天数',
                        key: 'belong_assign_time_day',
                        sortable: 'custom',
                        width: 108
                    },
                    { title: '部位', slot: 'labels', width: 200 },
                    { title: '患者标签', key: 'label', slot: 'label', width: 260 },
                    {
                        title: '城市',
                        key: 'city_name',
                        width: 200
                    },
                    { title: '病种', slot: 'disease', width: 200 },
                    { title: '对话方式', key: 'dialog_mode_name', width: 108 },
                    { title: '来源', width: 120, slot: 'channel' },
                    { title: '创建时间', key: 'created_at_str', sortable: 'custom', width: 135 },
                    {
                        title: '备注',
                        minWidth: 250,
                        key: 'remark',
                        ellipsis: true,
                        tooltip: true
                    },
                    { title: '操作', width: 100, slot: 'actions', fixed: 'right' }
                ],
                filterType: ''
            };
        },
        created(){
          this.initial()
          this.askData()
        },
        methods: {
           initial () {
                patientindextabtotal({ type: 0 }).then((res) => {
                  this.condition(res)
                });
            },
            askData () {
                this.loading = true;
                this.getparams()
                let params = JSON.parse(JSON.stringify(this.params))
                // params.area_code = this.area_code
                losslist(params).then((res) => {
                    let list = []
                    for (let item of res.list) {
                        if (+item.patient_data_type !== 0) item.realname = ''
                        list.push(item)
                    }
                    this.list = list
                    if (+this.params.page === 1) this.total = res.total;
                    this.$emit('alltotal', { key: 'arrive', total: res.total })
                    this.loading = false;
                });
            }
        }
    };
</script>
